﻿using ConfExpert.Forms.Base;
using System;
using System.Data;
using System.Windows.Forms;

namespace ConfExpert.Forms.Depo
{
    public partial class DetailTwins : XForm
    {
        int STlerId = 0;
        public DetailTwins(int _STlerId)
        {
            InitializeComponent();
            STlerId = _STlerId;
        }


        DataTable dt;
        BindingSource bs;
        private void DetailTwins_Load(object sender, EventArgs e)
        {
            
            

            dt = ExecuteDataTable("GetTwins", STlerId-1, -2);
            dt.TableName = "Twins";
            if (ds.Tables.Contains("Twins"))
                ds.Tables.Remove(dt);
            ds.Tables.Add(dt);
            bs = new BindingSource(ds, "Twins");
            Rebind();
            btnAyni.Click += new EventHandler(btnAyni_Click);
            btnFarkli.Click += new EventHandler(btnFarkli_Click);
            btnAnlasilmiyor.Click += new EventHandler(btnAnlasilmiyor_Click);
        }

        void btnAnlasilmiyor_Click(object sender, EventArgs e)
        {
            dt.Clear();
            dt.Merge(ExecuteDataTable("GetTwins", STlerId, -1));
            bs = new BindingSource(ds, "Twins");
            STlerId = intParse(bs, "STlerId");
        }

        private void Rebind()
        {
            STlerId = intParse(bs, "STlerId");

            pictureEdit1.DataBindings.Add("EditValue", bs, "Photo1");
            pictureEdit2.DataBindings.Add("EditValue", bs, "Photo2");
            labelControl1.DataBindings.Add("Text", bs, "Expl1");
            labelControl2.DataBindings.Add("Text", bs, "Expl2");
        }

        void btnFarkli_Click(object sender, EventArgs e)
        {
            dt.Clear();
            dt.Merge(ExecuteDataTable("GetTwins", STlerId, 0));
            bs = new BindingSource(ds, "Twins");
            STlerId = intParse(bs, "STlerId");
        }

        void btnAyni_Click(object sender, EventArgs e)
        {
            dt.Clear();
            dt.Merge(ExecuteDataTable("GetTwins", STlerId, 1));
            bs = new BindingSource(ds, "Twins");
            STlerId = intParse(bs, "STlerId");
        }
    }
}
